#include<iostream>
#include<map>
#include<cstring>
using namespace std;
const int N = 1e3 + 10, M = N * N;
int h[N], e[M], ne[M], idx;
int n, m;
int st[N];
bool st2[N];
int a1[N], b1[N];
map<int, int>mp;
int match[N];
int n1, n2;
void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx++;
}
void dfs(int u, int d)
{
	st[u] = d;
	for (int i = h[u]; ~i; i = ne[i]) {
		int j = e[i];
		if (!st[j]) {
			//cout << "j==" << j << "  st[j]==" << st[j] << endl;
			dfs(j, 3 - d);
		}
	}
}

bool dfs1(int u)
{
	for (int i = h[u]; ~i; i = ne[i]) {
		int j = e[i];
		if (!st2[j]) {
			st2[j] = 1;
			if (!match[j] || dfs1(match[j])) {
				match[j] = u;
				return 1;
			}
		}
	}
	return 0;
}
int main()
{
	cin >> n >> m;
	memset(h, -1, sizeof(h));
	for(int i = 0; i < m; i ++){
		int a, b;
		cin >> a >> b;
		a++, b++;
		a1[i] = a, b1[i] = b;
		add(a, b);
		//add(b, a);
	}
	for (int i = 1; i <= n; i++) {
		if (!st[i]) {
			dfs(i, 1);
		}
	}
	/*for (int i = 1; i <= n; i++) {
		cout << "i==" << i << "   st[i]==" << st[i] << endl;
	}*/
	memset(h, -1, sizeof(h));
	memset(e, 0, sizeof(e));
	memset(ne, 0, sizeof(ne));
	idx = 0;
	for (int i = 0; i < m; i++) {
		int a = a1[i], b = b1[i];
		//cout << a << "  " << b << endl;
		if (st[a] == 1) {
			add(a, b);
			if (!mp[a])n1++, mp[a] = 1;
			if (!mp[b])n2++, mp[b] = 1;
		}
		else {
			add(b, a);
			if (!mp[a])n2++, mp[a] = 1;
			if (!mp[b])n1++, mp[b] = 1;
		}
	}
	//cout << "n1==" << n1 << endl;
	//cout << "n2==" << n2 << endl;
	//cout << "st[5]==" << st[7] << endl;
	/*for (int i = 1; i <= n; i++) {
		if (st[i] == 1) {
			for (int j = h[i]; ~j; j = ne[j]) {
				int k = e[j];
				cout << i << "-->" << k << endl;
			}
		}
	}*/
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		memset(st2, 0, sizeof(st2));
		if (st[i] == 1) {
			if (dfs1(i))ans++;
		}
		
	}
	//cout << "ans==" << ans << endl;
	cout << n - ans << endl;
	return 0;
}